#-*-coding:utf-8-*-
import hou
from .preferences import Preferences

class Edit(object):
    def __init__(self):
        super(Edit,self).__init__()

    Preferences = Preferences()

    def undo(self):
        '''
        返回上一操作
        :return:
        '''
        hou.undos.performUndo()
        # print('undo')

    def redo(self):
        '''
        回到上一操作
        :return:
        '''
        hou.undos.performRedo()
        # print('redo')

    def undoEnabled(self):
        '''
        如果undo开启了则返回True
        :return:
        '''
        hou.undos.areEnabled()
        # print('undoEnabled')

    def undoDisabler(self):
        '''
        关闭undo功能
        :return:
        '''
        hou.undos.disabler()
        # print('disabler')


    def undoGroup(selff,groupName):
        '''
        将不能undo的步骤存入该组中
        :return:
        '''
        hou.undos.group(groupName)

    def undoClear(self):
        '''
        清空所有undo与redo内容
        :return:
        '''
        hou.undos.clear()
        # print('undoClear')

    def undoMemoryUsage(self):
        '''
        返回当前undos的记录数量
        :return: int
        '''
        return hou.undos.memoryUsage()
        # print('undoMemoryUsage')

    def undoMemoryUsageLimit(self):
        '''
        返回undos的最大操作次数
        :return: int
        '''
        return hou.undos.memoryUsageLimit()
        # print('undoMemoryUsageLimit')

    def undoLabels(self):
        '''
        返回undo的内容元组
        :return: tuple
        '''
        return hou.undos.undoLabels()
        # print('undoLabels')

    def redoLabels(self):
        '''
        返回redo的内容元组
        :return:
        '''
        return hou.undos.redoLabels()
        # print('redoLabels')



    def cut(self,items):
        '''
        剪切给定元素到剪切板
        :param items: 可以是节点面板中的任何事物，必须是列表形式
        :return:
        '''
        parent=items[0].creator()
        parent.copyItemsToClipboard(items)
        for i in items:
            i.destory()
        # print('cut')


    def copy(self,items):
        '''
        复制给定元素到剪切板
        :param items: 可以是节点面板中的任何事物，必须是列表形式
        :return:
        '''
        parent=items[0].creator()
        parent.copyItemsToClipboard(items)

        # print('copy')

    def paste(self):
        '''
        从剪切板复制元素到当前面板
        :return:
        '''
        net_editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
        parent=net_editor.pwd()
        net_editor.pasteItemsFromClipboard(net_editor.cursorPosition())
        # print('paste')









